package com.yuke.cloud.config;

import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.http.HttpMethod;

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        //basic auth 认证方式
        http.csrf().ignoringAntMatchers("/**").and()
                .authorizeRequests().anyRequest()
                .authenticated().and().httpBasic();
                // 自动登录
                //.and().rememberMe();
    }

    @Override
    public void configure(WebSecurity web) throws Exception {
        // 针对git的配置刷新请求忽略认证
        web.ignoring()
                .antMatchers(HttpMethod.POST,"/monitor");
    }
}
